package com.andnnl.ratelimit;

import cn.hutool.core.date.DateUtil;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by chenss on 2022/9/15.
 */
public class TestSum {
//    public static AtomicInteger num = new AtomicInteger(0);
//    public static AtomicLong num = new AtomicLong(0);
    public static long num = 0;

    public static void main(String[] args) throws InterruptedException {
        testInt();
    }

    static void testInt() throws InterruptedException {
        System.out.println(Thread.currentThread().getName() +" - "+ DateUtil.now() + " - 执行!");
        new Thread(() -> {
            for (int i = 0; i < 1000000000; i++) {
//                num.getAndAdd(1);
                num++;
            }
            System.out.println(Thread.currentThread().getName() +" - "+ DateUtil.now() + " - 执行结束!"+num);
        }).start();
        Thread.sleep(10);
        System.out.println("num = " + num);
    }


}
